﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DIProject.Dictionary
{
    public partial class Countries : Form
    {
        public Countries()
        {
            InitializeComponent();
        }

        private void Countries_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dictionary.Countries' table. You can move, or remove it, as needed.
            this.countriesTableAdapter.Fill(this.dictionary.Countries,DIProject.Data.Sync.IsAdmin);

        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.Rows[e.RowIndex].Selected = true;
            DataRowView dr = dataGridView1.SelectedRows[0].DataBoundItem as DataRowView;
            if (dr != null)
            {
                DIProject.DataSets.Dictionary.CountriesRow cr = dr.Row as DIProject.DataSets.Dictionary.CountriesRow;
                if (cr != null)
                {
                    Dictionary.CountriesDetail cd = new CountriesDetail(DIProject.Util.ActionType.Update, cr.Id, this);
                    cd.Show();
                }
            }
        }

        private void tsbAdd_Click(object sender, EventArgs e)
        {
            Dictionary.CountriesDetail cd = new CountriesDetail(DIProject.Util.ActionType.Insert, -1, this);
            cd.Show();
        }

        private void tsbNew_Click(object sender, EventArgs e)
        {
            this.countriesTableAdapter.Fill(this.dictionary.Countries,DIProject.Data.Sync.IsAdmin);
        }
    }
}